<form id="infoeditfm" method="post">
    <input type="hidden" name="id" id="id" value="<?php echo $dataset['id'];?>"/>
    <table border="0" width="100%" cellspacing="1" cellpadding="5" bgcolor="#c4d3e1"
           style="text-align:left; line-height:18px;">
        <tr bgcolor="#FFFFFF">
            <td style="line-height:30px;" width="20%">类别：</td>
            <td width="80%">
                <SELECT name="type" id="type" style="width:153px; height:25px;" size='1'>
                    <OPTION
                    <?php echo $dataset['type']==1?'selected':'';?>  value="1">基本信息</OPTION>
                    <OPTION
                    <?php echo $dataset['type']==2?'selected':'';?>  value="2">支付宝信息</OPTION>
                    <OPTION
                    <?php echo $dataset['type']==3?'selected':'';?>  value="3">微信账号</OPTION>
                    <OPTION
                    <?php echo $dataset['type']==4?'selected':'';?>  value="4">七牛CND</OPTION>
                    <OPTION
                    <?php echo $dataset['type']==5?'selected':'';?>  value="5">阿里大于</OPTION>
                    <OPTION
                    <?php echo $dataset['type']==6?'selected':'';?>  value="6">极光推送</OPTION>
                </SELECT>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td style="line-height:30px;" width="20%">名称：</td>
            <td width="80%"><input name="title" id="title" type="text" value="<?php echo $dataset['title'];?>"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入标题.." required="true"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td style="line-height:30px;" width="20%">键：</td>
            <td width="80%"><input name="key" id="key" type="text" value="<?php echo $dataset['key'];?>"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入键.." required="true"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td style="line-height:30px;" width="20%">值：</td>
            <td width="80%"><textarea name="value" id="value" style="width:450px; height:138px; text-align:left;"
                                      class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                      placeholder="请输入值.." required="true"><?php echo $dataset['value'];?></textarea>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td style="line-height:30px;" width="20%">编码：</td>
            <td width="80%"><label><input id="encode" name="encode" type="checkbox"
                                          value="1" <?php if($dataset['encode']==1){echo 'checked="checked"';}?> >
                base64</label></td>
        </tr>
    </table>
</form>

<script>
    $(function () {
        $('#infoupdatesubmit').click(function (data) {
            if ($("input:checkbox[name='encode']").is(":checked")) {
                $.base64.utf8encode = true;
                var encodecontent = $.base64.btoa($("#value").val());
                $.post("/admin/index/infoupdate", {
                    "id": $('#id').val(),
                    "type": $('#type').val(),
                    "title": $('#title').val(),
                    'key': $('#key').val(),
                    'value': encodecontent,
                    'encode': 1
                }, function (data) {
                    if (data.ret == 0) {
                        $.messager.show({
                            title: '提示',
                            msg: data.msg,
                            timeout: 3000,
                            showType: 'slide'
                        });
                        $('#infoeditfm').form('clear');
                        $("#infodlg").dialog('close');
                        $("#info<?php echo $dataset['type'];?>").datagrid('reload');
                    } else {
                        $.messager.alert('提示', data.msg, 'warning');
                    }
                }, 'json');
            } else {
                $('#infoeditfm').form('submit', {
                    url: '/admin/index/infoupdate',
                    success: function (data) {
                        var data = eval('(' + data + ')');
                        if (data.ret == 0) {
                            $.messager.show({
                                title: '提示',
                                msg: data.msg,
                                timeout: 3000,
                                showType: 'slide'
                            });
                            $('#infoeditfm').form('clear');
                            $("#infodlg").dialog('close');
                            $("#info<?php echo $dataset['type'];?>").datagrid('reload');
                        } else {
                            $.messager.alert('提示', data.msg, 'warning');
                        }
                    }
                });
            }
        })
    });
</script>
